Skip to content

Conversation

@Lash-L
Copy link
Collaborator

@Lash-L Lash-L commented Dec 10, 2025

This will help with future reverse engineering, we only log once

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
roborock/data/containers.py 93.29% <100.00%> (+0.08%) ⬆️

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds debug logging to track unknown keys encountered during deserialization of Roborock data classes, logging each unique key only once to aid in future reverse engineering efforts.

  • Added a class-level set _missing_logged to track which unknown keys have been logged
  • Implemented logging logic that emits a debug message when an unknown key is first encountered, including both original and decamelized key names
  • Imported ClassVar type hint to properly annotate the shared state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

class RoborockBase:
"""Base class for all Roborock data classes."""

_missing_logged: ClassVar[set[str]] = set()
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shared class variable _missing_logged is not thread-safe. If from_dict is called concurrently from multiple threads, race conditions could occur when checking membership and adding to the set. Consider using a threading.Lock or a thread-safe alternative like threading.RLock() to protect access to this shared state, or use a thread-safe data structure.

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +105
if (log_key := f"{cls.__name__}.{key}") not in RoborockBase._missing_logged:
_LOGGER.debug(
"Key '%s' (decamelized: '%s') not found in %s fields, skipping",
orig_key,
key,
cls.__name__,
)
RoborockBase._missing_logged.add(log_key)
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logging behavior for unknown keys lacks test coverage. Consider adding a test that verifies: (1) a debug log is emitted when an unknown key is encountered for the first time, (2) the log is not emitted again for subsequent occurrences of the same key in the same class, and (3) the class name and both original and decamelized keys are included in the log message. The existing test_ignore_unknown_keys test could be extended to verify this behavior using a mock logger or caplog fixture.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@allenporter allenporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also consider storing this in diagnostic data for the traits to dump if thats also helpful.

@Lash-L
Copy link
Collaborator Author

Lash-L commented Dec 10, 2025

Could also consider storing this in diagnostic data for the traits to dump if thats also helpful.

A good follow up, I'll explore doing that as well

@Lash-L Lash-L merged commit 81dde05 into main Dec 10, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants